package L01;

class MyRunnable implements Runnable{//用接口实现Thraed

    @Override
    public void run () {
        while(true){
            System.out.println ("hello thread");
            try {
                Thread.sleep (1000);
            } catch (InterruptedException e) {
                throw new RuntimeException (e);
            }
        }
    }
}

//Runnable可执行任务，创建线程
public class T02 {
    public static void main (String[] args) throws InterruptedException {
        //向上转型
        Runnable runnable=new MyRunnable();
        Thread thread=new Thread (runnable);
        thread.start ();

        while(true){
            System.out.println ("hello main");
            Thread.sleep (1000);
        }
    }
}
